home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1995 #5 & #6
/
Amiga Plus CD - 1995 - No. 5 and 6.iso
/
pd
/
netz
/
term
/
extras
/
source
/
gtlayout-source.lha
/
LTP_DefaultEditRoutine.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-25
|
3KB
|
156 lines
/* GadTools layout toolkit
**
** Copyright © 1993-1995 by Olaf `Olsen' Barthel
** Freely distributable.
*/
#include "gtlayout_global.h"
ULONG __asm __saveds
LTP_DefaultEditRoutine(register __a0 struct Hook *Hook,register __a2 struct SGWork *Work,register __a1 ULONG *Msg)
{
if(*Msg == SGH_KEY)
{
if(Work -> IEvent -> ie_Code == 0x5F)
{
LayoutHandle *Handle = Hook -> h_Data;
if(Handle -> HelpHook)
{
Work -> Code = 0x5F;
Work -> Actions = (Work -> Actions & ~SGA_BEEP) | SGA_END | SGA_USE;
LTP_AddHistory(Work);
return(TRUE);
}
}
if(Work -> IEvent -> ie_Code == CURSORUP || Work -> IEvent -> ie_Code == CURSORDOWN)
LTP_HandleHistory(Work);
if(Work -> EditOp == EO_ENTER)
{
LayoutHandle *Handle = Hook -> h_Data;
ObjectNode *Node;
BOOLEAN Activate = TRUE;
if(GETOBJECT(Work -> Gadget,Node))
{
if(Node -> Type == STRING_KIND)
{
if(Node -> Special . String . LastGadget)
Activate = FALSE;
}
#ifndef DO_HEXHOOK
else
{
if(Node -> Type == INTEGER_KIND)
{
if(Node -> Special . Integer . LastGadget)
Activate = FALSE;
}
}
#endif
}
if(!(Work -> IEvent -> ie_Qualifier & QUALIFIER_SHIFT))
{
if(Activate && Handle -> AutoActivate)
Work -> Actions |= SGA_NEXTACTIVE;
if(!(Work -> Actions & SGA_NEXTACTIVE))
Work -> Code = '\r';
}
}
if(Work -> IEvent -> ie_Code == CURSORRIGHT && (Work -> IEvent -> ie_Qualifier & QUALIFIER_CONTROL))
{
if(Work -> BufferPos != Work -> NumChars)
{
WORD i,Position = -1;
for(i = Work -> BufferPos ; i < Work -> NumChars ; i++)
{
if(Work -> WorkBuffer[i] == ' ')
{
for( ; i < Work -> NumChars ; i++)
{
if(Work -> WorkBuffer[i] != ' ')
{
Position = i;
break;
}
}
break;
}
}
if(Position != -1)
Work -> BufferPos = Position;
else
Work -> BufferPos = Work -> NumChars;
Work -> EditOp = EO_MOVECURSOR;
}
}
if(Work -> IEvent -> ie_Code == CURSORLEFT && (Work -> IEvent -> ie_Qualifier & QUALIFIER_CONTROL))
{
if(Work -> BufferPos)
{
WORD i,Position = -1;
for(i = Work -> BufferPos ; i >= 0 ; i--)
{
if(Work -> WorkBuffer[i] != ' ')
{
Position = i;
break;
}
}
if(Position == -1)
Position = 0;
if(Position)
{
i = Position;
Position = -1;
for( ; i >= 0 ; i--)
{
if(Work -> WorkBuffer[i] == ' ')
{
Position = i + 1;
break;
}
}
}
if(Position != -1)
Work -> BufferPos = Position;
else
Work -> BufferPos = 0;
Work -> EditOp = EO_MOVECURSOR;
}
}
if(Work -> Actions & SGA_END)
LTP_AddHistory(Work);
}
else
{
if(*Msg != SGH_CLICK)
return(FALSE);
}
return(TRUE);
}